import { createRouter, createWebHashHistory,createWebHistory } from 'vue-router'
import AddQuestion from '@/views/AddQuestion.vue'
import AddQuestions from '@/views/AddQuestions.vue'
import AddQuestionNoDialoge from '@/views/AddQuestionNoDialoge.vue'
import GetPaper from '@/views/GetPaper.vue'
import ShowQuestion from '@/views/ShowQuestion.vue'
import ShowQuestionPrivate from '@/views/ShowQuestionPrivate.vue'
import Square from '@/views/Square.vue'
import Index from '@/views/Index.vue'
import Login from '@/views/Login.vue'
import Signin from '@/views/Signin.vue'
import AutomaticGroup from '@/views/AutomaticGroup.vue'
import preludeGroup from '@/views/preludeGroup.vue'
import NCEEdetailPoint from '@/views/NCEEdetailPoint.vue'
import JointTestPaper from '@/views/JointTestPaper.vue'
import AddPaperByFileStepThree from '@/views/AddPaperByFileStepThree.vue'
import AddPaperByFileStepOne from '@/views/AddPaperByFileStepOne.vue'
import AddPaperByFileStepTwo from '@/views/AddPaperByFileStepTwo.vue'
import AddPaperPrivate from '@/views/AddPaperPrivate.vue'
import ViewQuestionDetail from '@/views/ViewQuestionDetail.vue'
import VerifyQuestionsOfPaper from '@/views/VerifyQuestionsOfPaper.vue'
import ImportQuestions from '@/views/ImportQuestions.vue'
import AddGood from '@/views/AddGood.vue'
import DownloadFile from '@/views/DownloadFile.vue'
import AddPaperBySelectQuestionList from '@/views/AddPaperBySelectQuestionList.vue'
import UserInformation from '@/views/UserInformation.vue'
import ChangePassword from '@/views/userCenter/ChangePassword.vue'
import MyNotification from '@/views/userCenter/MyNotification.vue'
import MyBankPoint from '@/views/userCenter/MyBankPoint.vue'
import Withdraw from '@/views/userCenter/Withdraw.vue'
import Recharge from '@/views/userCenter/Recharge.vue'
import MyFavoriteQuestions from '@/views/MyFavoriteQuestions.vue'
import UserCenter from '@/views/UserCenter.vue'
import AdminCenter from '@/views/AdminCenter.vue'
import ActivateAccountManage from '@/views/adminManage/ActivateAccountManage.vue'
import VIPManage from '@/views/adminManage/VIPManage.vue'
import NicknameManage from '@/views/adminManage/NicknameManage.vue'
import JointPaperManage from '@/views/adminManage/JointPaperManage.vue'
import GeneralPaperManage from '@/views/adminManage/GeneralPaperManage.vue'
import NotPaperQuestionManage from '@/views/adminManage/NotPaperQuestionManage.vue'
import QuestionPrivateManage from '@/views/adminManage/QuestionPrivateManage.vue'
import GuidePaperManage from '@/views/adminManage/GuidePaperManage.vue'
import JointPaperQuestionManage from '@/views/adminManage/JointPaperQuestionManage.vue'
import GeneralPaperQuestionManage from '@/views/adminManage/GeneralPaperQuestionManage.vue'
import FeekbackManage from '@/views/adminManage/FeekbackManage.vue'
import WithdrawLogManage from '@/views/adminManage/WithdrawLogManage.vue'
import RechargeLogManage from '@/views/adminManage/RechargeLogManage.vue'
import MyCreatePaper from '@/views/userCenter/MyCreatePaper.vue'
import MyCreateGuidePaper from '@/views/userCenter/MyCreateGuidePaper.vue'
import MyCreateQuestion from '@/views/userCenter/MyCreateQuestion.vue'
import MyPrivateQuestion from '@/views/userCenter/MyPrivateQuestion.vue'
import MyCreateQuestionAll from '@/views/userCenter/MyCreateQuestionAll.vue'
import ResetPassword from '@/views/userCenter/ResetPassword.vue'
import FrequentQuestions from '@/views/userCenter/FrequentQuestions.vue'
import GuidePaper from '@/views/GuidePaper.vue'
import AddGuidePaper from '@/views/AddGuidePaper.vue'
import FaceRecognition from '@/views/ai/FaceRecognition.vue'
import ChatCompletion from '@/views/ai/ChatCompletion.vue'
import Tex2pdf from '@/views/ai/Tex2pdf.vue'
import Pdf2Latex from '@/views/ai/Pdf2Latex.vue'
import AccordingToExaminationPaper from '@/views/puzzle/AccordingToExaminationPaper.vue'
import WrongQuestionSets from '@/views/puzzle/WrongQuestionSets.vue'
import AddPaperManual from '@/views/AddPaperManual.vue'
import AddVideoStepOne from '@/views/AddVideoStepOne.vue'
import AddNode from '@/views/userCenter/AddNode.vue'
import HandingWriteOCR from '@/views/HandingWriteOCR.vue'

import { localGet, localSet,  pathMap } from '@/utils'
import { ElMessage  } from 'element-plus'
import axios from '@/utils/axios'
const router = createRouter({
  history: createWebHashHistory(), // hash 模式
  // history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'index',
      component: Index
    },
    {
      path: '/addGood',
      name: 'addGood',
      component: AddGood
    },
    {
      path: '/addQuestions',
      name: 'addQuestions',
      component: AddQuestions
    },
    {
      path: '/addPaperManual',
      name: 'addPaperManual',
      component: AddPaperManual
    },
    {
      path: '/square',
      name: 'square',
      component: Square
    },   
 
    {
      path: '/getQuestionsById',
      name: 'getQuestionsById',
      component: ShowQuestion
    },
    {
      path: '/getQuestionsByKnowledgepoint',
      name: 'getQuestionsByKnowledgepoint',
      component: ShowQuestion
    },
    {
      path: '/showQuestionPrivate',
      name: 'showQuestionPrivate',
      component: ShowQuestionPrivate
    },
    {
      path: '/getQuestionsByChapter',
      name: 'getQuestionsByChapter',
      component: ShowQuestion
    },
    {
      path: '/getQuestionsBySection',
      name: 'getQuestionsBySection',
      component: ShowQuestion
    },
    {
      path: '/getQuestionsByCourse',
      name: 'getQuestionsByCourse',
      component: ShowQuestion
    },
    {
      path: '/searchQuestion',
      name: 'searchQuestion',
      component: ShowQuestion
    },
    {
      path: '/getPaper',
      name: 'getPaper',
      component: GetPaper
    },
    {
      path: '/addQuestion',
      name: 'addQuestion',
      component: AddQuestion
    },
     {
      path: '/addQuestionNoDialoge',
      name: 'addQuestionNoDialoge',
      component: AddQuestionNoDialoge
    },
    {
      path: '/automaticGroup',
      name: 'automaticGroup',
      component: AutomaticGroup
    },
    {
      path: '/preludeGroup',
      name: 'preludeGroup',
      component: preludeGroup
    },
    {
      path: '/nCEEdetailPoint',
      name: 'nCEEdetailPoint',
      component: NCEEdetailPoint
    },
    {
      path: '/jointTestPaper',
      name: 'jointTestPaper',
      component: JointTestPaper
    },
    {
      path: '/addPaperByFileStepOne',
      name: 'addPaperByFileStepOne',
      component: AddPaperByFileStepOne
    },
    {
      path: '/addPaperPrivate',
      name: 'addPaperPrivate',
      component: AddPaperPrivate
    },
    {
      path: '/addPaperByFileStepTwo',
      name: 'addPaperByFileStepTwo',
      component: AddPaperByFileStepTwo
    },
    {
      path: '/addPaperByFileStepThree',
      name: 'addPaperByFileStepThree',
      component: AddPaperByFileStepThree
    },
    {
      path: '/viewQuestionDetail',
      name: 'viewQuestionDetail',
      component: ViewQuestionDetail
    },
    {
      path: '/verifyQuestionsOfPaper',
      name: 'verifyQuestionsOfPaper',
      component: VerifyQuestionsOfPaper
    },
    {
      path: '/importQuestions',
      name: 'importQuestions',
      component: ImportQuestions
    },
    {
      path: '/downloadFile',
      name: 'downloadFile',
      component: DownloadFile
    },
    {
      path: '/addPaperBySelectQuestionList',
      name: 'addPaperBySelectQuestionList',
      component: AddPaperBySelectQuestionList
    },
   
    {
      path: '/getQuestionsByPaper',
      name: 'getQuestionsByPaper',
      component: ShowQuestion
    },   
    {
      path: '/userCenter',
      name: 'userCenter',
      component: UserCenter,
    },
    {
      path: '/userCenter/userInformation',
      name: 'userInformation',
      component: UserInformation,
    },
    {
      path: '/userCenter/changePassword',
      name: 'changePassword',
      component: ChangePassword,
    },
    {
      path: '/resetPassword',
      name: 'resetPassword',
      component: ResetPassword,
    },
    {
      path: '/userCenter/myFavoriteQuestions',
      name: 'myFavoriteQuestions',
      component: MyFavoriteQuestions,
    },
    {
      path: '/userCenter/myCreatePaper',
      name: 'myCreatePaper',
      component: MyCreatePaper,
    },
    {
      path: '/userCenter/frequentQuestions',
      name: 'frequentQuestions',
      component: FrequentQuestions,
    },
    {
      path: '/userCenter/myNotification',
      name: 'myNotification',
      component: MyNotification,
    },
    {
      path: '/userCenter/myBankPoint',
      name: 'myBankPoint',
      component: MyBankPoint,
    },
    {
      path: '/userCenter/withdraw',
      name: 'withdraw',
      component: Withdraw,
    },
    {
      path: '/userCenter/recharge',
      name: 'recharge',
      component: Recharge,
    },
    {
      path: '/userCenter/myCreateGuidePaper',
      name: 'myCreateGuidePaper',
      component: MyCreateGuidePaper,
    },
    {
      path: '/userCenter/myCreateQuestion',
      name: 'myCreateQuestion',
      component: MyCreateQuestion,
    },
    {
      path: '/userCenter/myPrivateQuestion',
      name: 'myPrivateQuestion',
      component: MyPrivateQuestion,
    },
    {
      path: '/userCenter/myCreateQuestionAll',
      name: 'myCreateQuestionAll',
      component: MyCreateQuestionAll,
    },
    {
      path: '/userCenter/MyNotification',
      name: 'MyNotification',
      component: MyNotification,
    },
    {
      path: '/adminCenter',
      name: 'adminCenter',
      component: AdminCenter,
    },
    {
      path: '/adminCenter/activateAccountManage',
      name: 'activateAccountManage',
      component: ActivateAccountManage,
    },
    {
      path: '/adminCenter/VIPManage',
      name: 'VIPManage',
      component: VIPManage,
    },
    {
      path: '/adminCenter/nicknameManage',
      name: 'nicknameManage',
      component: NicknameManage,
    },
     {
      path: '/adminCenter/guidePaperManage',
      name: 'guidePaperManage',
      component: GuidePaperManage,
    },
    {
      path: '/adminCenter/jointPaperManage',
      name: 'jointPaperManage',
      component: JointPaperManage,
    },
    {
      path: '/adminCenter/generalPaperManage',
      name: 'generalPaperManage',
      component: GeneralPaperManage,
    },
    {
      path: '/adminCenter/jointPaperQuestionManage',
      name: 'jointPaperQuestionManage',
      component: JointPaperQuestionManage,
    },
    {
      path: '/adminCenter/generalPaperQuestionManage',
      name: 'generalPaperQuestionManage',
      component: GeneralPaperQuestionManage,
    },
    {
      path: '/adminCenter/generalFeekbackManage',
      name: 'generalFeekbackManage',
      component: FeekbackManage,
    },
    {
      path: '/adminCenter/questionFeedbackManage',
      name: 'questionFeekbackManage',
      component: FeekbackManage,
    },
    {
      path: '/adminCenter/guidePaperFeedbackManage',
      name: 'guidePaperFeekbackManage',
      component: FeekbackManage,
    },
    {
      path: '/adminCenter/feedbackManage',
      name: 'feedbackManage',
      component: FeekbackManage,
    },
    {
      path: '/adminCenter/notPaperQuestionManage',
      name: 'notPaperQuestionManage',
      component: NotPaperQuestionManage,
    },
    {
      path: '/adminCenter/questionPrivateManage',
      name: 'questionPrivateManage',
      component: QuestionPrivateManage,
    },
    {
      path: '/adminCenter/withdrawLogManage',
      name: 'withdrawLogManage',
      component: WithdrawLogManage,
    },
    {
      path: '/adminCenter/rechargeLogManage',
      name: 'rechargeLogManage',
      component: RechargeLogManage,
    },
    {
      path: '/getQuestionsByGenaralPaper',
      name: 'getQuestionsByGenaralPaper',
      component: ShowQuestion,
    },
    {
      path: '/getGuidePapersByKnowledgepoint',
      name: 'getGuidePapersByKnowledgepoint',
      component: GuidePaper,
    },
    {
      path: '/addVideoStepOne',
      name: 'addVideoStepOne',
      component: AddVideoStepOne,
    },
    {
      path: '/addGuidePaper',
      name: 'addGuidePaper',
      component: AddGuidePaper,
    },
    {
      path: '/faceRecognition',
      name: 'faceRecognition',
      component: FaceRecognition,
    },
    {
      path: '/chatCompletion',
      name: 'chatCompletion',
      component: ChatCompletion,
    },
    {
      path: '/puzzle/accordingToExaminationPaper',
      name: 'accordingToExaminationPaper',
      component: AccordingToExaminationPaper,
    },
    {
      path: '/puzzle/wrongQuestionSets',
      name: 'wrongQuestionSets',
      component: WrongQuestionSets,
    },
    {
      path: '/signin',
      name: 'signin',
      component: Signin
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/userCenter/addNode',
      name: 'addNode',
      component: AddNode
    },
    {
      path: '/handingWriteOCR',
      name: 'handingWriteOCR',
      component: HandingWriteOCR
    },
    {
      path: '/tex2pdf',
      name: 'tex2pdf',
      component: Tex2pdf
    },
    {
      path: '/pdf2Latex',
      name: 'pdf2Latex',
      component: Pdf2Latex
    },
    
  ]
})
router.beforeEach((to, from, next)=>{
  if(to.path=='/signin' || to.path=='/resetPassword' || to.path=='/chatCompletion' || to.path=='/' || to.path=='/tex2pdf' || to.path=='/handingWriteOCR'){
    next()
  }else if(to.path=='/login'){
    next()
    }else if(localGet('token')==''||localGet('token')==undefined){
      ElMessage.error("你还没登录，无法访问当前内容，请登录")
      next('/login')
    }else{
      next()
    }
})
export default router